New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test for RepeatDataset #26415
Test for RepeatDataset #26415
Conversation
NodeDef node_def_; | ||
}; | ||
|
||
struct TestParam { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/TestParam/TestCase
}; | ||
|
||
// Test case 1: finite repetition. | ||
TestParam TestCase1() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/TestCase1/FiniteRepeatTestCase/ ... and similarly for the other test cases
return Status::OK(); | ||
} | ||
|
||
Status CreateDatasetFromTestCase(const TestParam &test_case) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for FromTestCase
return Status::OK(); | ||
} | ||
|
||
Status CreateIteratorFromTestCase(const TestParam &test_case) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for FromTestCase
return Status::OK(); | ||
} | ||
|
||
std::unique_ptr<OpKernel> dataset_kernel_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid storing this state in member variables. There is no need to do this and it hurts readability.
std::vector<Tensor> out_tensors; | ||
|
||
if (test_case.count < 0) { | ||
int fake_infinite_repetition = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of a cryptic variable name, add a comment here that says that we test only test a finite number of steps of the infinite sequence, and then use a for loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feihugis thank you for the PR, I did a pass and left some comments
- Change the class name and function name to improve readability - Remove dataset_kernel_ member variable - Refactor the forever repeat test
@jsimsa Thanks for your review! The comments are addressed in this commit. Could you have a look when you have time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@feihugis thank you for the changes, one more comment
TF_RETURN_IF_ERROR( | ||
CreateIteratorContext(dataset_kernel_ctx_.get(), &iterator_ctx_)); | ||
TF_RETURN_IF_ERROR( | ||
dataset_->MakeIterator(iterator_ctx_.get(), "Iterator", &iterator_)); | ||
return Status::OK(); | ||
} | ||
|
||
std::unique_ptr<OpKernel> dataset_kernel_; | ||
std::unique_ptr<OpKernelContext> dataset_kernel_ctx_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment was meant for all of the internal state (dataset_kernel_
, dataset_kernel_ctx_
, and iterator_ctx_
).
While writing the code this way makes it less verbose, it makes it harder to understand what is going on in case someone would like to modify the code.
@jsimsa This commit removes the internal member variables, and move the code in the helper class to each test to improve the code readability. Could you have a look at the changes? Any suggestions are very welcome. |
PiperOrigin-RevId: 237914360
This PR adds the test for the kernel of
RepeatDataset
.cc @rachellim @jsimsa